home *** CD-ROM | disk | FTP | other *** search
/ MacHack 2000 / MacHack 2000.toast / pc / The Hacks / Mixed Mode Maddness / Emulator / Source / GetValue.c < prev    next >
Encoding:
C/C++ Source or Header  |  2000-06-24  |  5.7 KB  |  296 lines

  1. #include "GetValue.h"
  2.  
  3. //////////////////////////////////////////////
  4. //
  5. // GetImmediateValue
  6. //
  7. //////////////////////////////////////////////
  8. UInt8 GetImmediateValue(void)
  9. {
  10.     UInt8* curbyte = gStartofProg + pc++;
  11.     return *curbyte;
  12. }
  13.  
  14. //////////////////////////////////////////////
  15. //
  16. // GetAbsoluteValue
  17. //
  18. //////////////////////////////////////////////
  19. UInt8 GetAbsoluteValue(void)
  20. {
  21.     UInt8* curbyte = GetAbsoluteAddress();
  22.     return *curbyte;
  23. }
  24.  
  25. //////////////////////////////////////////////
  26. //
  27. // GetZeroPageValue
  28. //
  29. //////////////////////////////////////////////
  30. UInt8 GetZeroPageValue(void)
  31. {
  32.     UInt8* curbyte = GetZeroPageAddress();
  33.     return *curbyte;
  34. }
  35.  
  36. //////////////////////////////////////////////
  37. //
  38. // GetZeroPageXValue
  39. //
  40. //////////////////////////////////////////////
  41. UInt8 GetZeroPageXValue(void)
  42. {
  43.     UInt8* curbyte = GetZeroPageXAddress();
  44.     return *curbyte;
  45. }
  46.  
  47. //////////////////////////////////////////////
  48. //
  49. // GetZeroPageYValue
  50. //
  51. //////////////////////////////////////////////
  52. UInt8 GetZeroPageYValue(void)
  53. {
  54.     UInt8* curbyte = GetZeroPageYAddress();
  55.     return *curbyte;
  56. }
  57.  
  58. //////////////////////////////////////////////
  59. //
  60. // GetIndXValue
  61. //
  62. //////////////////////////////////////////////
  63. UInt8 GetIndXValue(void)
  64. {
  65.     UInt8* curbyte = GetIndXAddress();
  66.     return *curbyte;
  67. }
  68.  
  69. //////////////////////////////////////////////
  70. //
  71. // GetIndYValue
  72. //
  73. //////////////////////////////////////////////
  74. UInt8 GetIndYValue(void)
  75. {
  76.     UInt8* curbyte = GetIndYAddress();
  77.     return *curbyte;
  78. }
  79.  
  80. //////////////////////////////////////////////
  81. //
  82. // GetAbsoluteXValue
  83. //
  84. //////////////////////////////////////////////
  85. UInt8 GetAbsoluteXValue(void)
  86. {
  87.     UInt8*  curbyte = GetAbsoluteXAddress();
  88.     return *curbyte;
  89. }
  90.  
  91. //////////////////////////////////////////////
  92. //
  93. // GetAbsoluteYValue
  94. //
  95. //////////////////////////////////////////////
  96. UInt8 GetAbsoluteYValue(void)
  97. {
  98.     UInt8*  curbyte = GetAbsoluteYAddress();
  99.     return *curbyte;
  100. }
  101.  
  102. //////////////////////////////////////////////
  103. //
  104. // GetRelativeValue
  105. //
  106. //////////////////////////////////////////////
  107. UInt8 GetRelativeValue(void)
  108. {
  109.     UInt8* curbyte = gStartofProg + pc++;
  110.     return *curbyte;
  111. }
  112.  
  113. //////////////////////////////////////////////
  114. //
  115. // GetAbsoluteAddress
  116. //
  117. //////////////////////////////////////////////
  118. UInt8* GetAbsoluteAddress(void)
  119. {
  120.     UInt8*  curbyte = gStartofProg + pc++;
  121.     UInt16 addr = *curbyte;
  122.  
  123.     curbyte = gStartofProg + pc++;
  124.     addr |= (((UInt16)*curbyte) << 8);
  125.     return gStartofProg + addr;
  126. }
  127.  
  128. //////////////////////////////////////////////
  129. //
  130. // GetAbsoluteYAddress
  131. //
  132. //////////////////////////////////////////////
  133. UInt8* GetAbsoluteYAddress(void)
  134. {
  135.     UInt8*  curbyte = gStartofProg + pc++;
  136.     UInt16 addr = *curbyte;
  137.  
  138.     curbyte = gStartofProg + pc++;
  139.     addr |= (((UInt16)*curbyte) << 8);
  140.     addr += regY;
  141.     curbyte = gStartofProg + addr;
  142.     return curbyte;
  143. }
  144.  
  145. //////////////////////////////////////////////
  146. //
  147. // GetZeroPageAddress
  148. //
  149. //////////////////////////////////////////////
  150. UInt8* GetZeroPageAddress(void)
  151. {
  152.     UInt16 addr = 0;
  153.     UInt8* curbyte;
  154.  
  155.     curbyte = ((UInt8*)gStartofProg) + pc++;
  156.     addr |= *curbyte;
  157.     return ((UInt8*)gPageZero) + addr;
  158. }
  159.  
  160. //////////////////////////////////////////////
  161. //
  162. // GetAccumulatorAddress
  163. //
  164. //////////////////////////////////////////////
  165. UInt8* GetAccumulatorAddress(void)
  166. {
  167.     return ®A;
  168. }
  169.  
  170. //////////////////////////////////////////////
  171. //
  172. // GetZeroPageXAddress
  173. //
  174. //////////////////////////////////////////////
  175. UInt8* GetZeroPageXAddress(void)
  176. {
  177.     UInt16 addr = 0;
  178.     UInt8* curbyte;
  179.  
  180.     curbyte = ((UInt8*)gStartofProg) + pc++;
  181.     addr |= *curbyte;
  182.  
  183.     addr += regX;
  184.     curbyte = ((UInt8*)gPageZero) + addr;
  185.     return curbyte;
  186. }
  187.  
  188. //////////////////////////////////////////////
  189. //
  190. // GetZeroPageYAddress
  191. //
  192. //////////////////////////////////////////////
  193. UInt8* GetZeroPageYAddress(void)
  194. {
  195.     UInt16 addr = 0;
  196.     UInt8* curbyte;
  197.  
  198.     curbyte = ((UInt8*)gStartofProg) + pc++;
  199.     addr |= *curbyte;
  200.  
  201.     addr += regY;
  202.     curbyte = ((UInt8*)gPageZero) + addr;
  203.     return curbyte;
  204. }
  205.  
  206. //////////////////////////////////////////////
  207. //
  208. // GetAbsoluteXAddress
  209. //
  210. //////////////////////////////////////////////
  211. UInt8* GetAbsoluteXAddress(void)
  212. {
  213.     UInt8*  curbyte = gStartofProg + pc++;
  214.     UInt16 addr = *curbyte;
  215.  
  216.     curbyte = gStartofProg + pc++;
  217.     addr |= (((UInt16)*curbyte) << 8);
  218.  
  219.     addr += regX;
  220.  
  221.     curbyte = gStartofProg + addr;
  222.     return curbyte;
  223. }
  224.  
  225. //////////////////////////////////////////////
  226. //
  227. // GetIndXAddress
  228. //
  229. //////////////////////////////////////////////
  230. UInt8* GetIndXAddress(void)
  231. {
  232.     UInt8 opByte;
  233.     UInt16 addr = 0;
  234.     UInt8* curbyte;
  235.  
  236.     curbyte = ((UInt8*)gStartofProg) + pc++;
  237.     opByte = *curbyte;
  238.     opByte += regX;
  239.     addr = *(((UInt8*)gPageZero) + opByte);
  240.     addr |= (((UInt16)*(gPageZero + (opByte + 1))) << 8);
  241.  
  242.     curbyte = gStartofProg + addr;
  243.     return curbyte;
  244. }
  245.  
  246. //////////////////////////////////////////////
  247. //
  248. // GetIndYAddress
  249. //
  250. //////////////////////////////////////////////
  251. UInt8* GetIndYAddress(void)
  252. {
  253.     UInt8 opByte;
  254.     UInt16 addr = 0;
  255.     UInt8* curbyte;
  256.  
  257.     curbyte = ((UInt8*)gStartofProg) + pc++;
  258.     opByte = *curbyte;
  259.     addr = *(gPageZero + opByte);
  260.     addr |= (((UInt16)*(gPageZero + (opByte + 1))) << 8);
  261.     addr += regY;
  262.     curbyte = gStartofProg + addr;
  263.     return curbyte;
  264. }
  265.  
  266. //////////////////////////////////////////////
  267. //
  268. // GetAbsolutePCAddress
  269. //
  270. //////////////////////////////////////////////
  271. UInt16 GetAbsolutePCAddress(void)
  272. {
  273.     UInt8*  curbyte = gStartofProg + pc++;
  274.     UInt16 addr = *curbyte;
  275.  
  276.     curbyte = gStartofProg + pc++;
  277.     addr |= (((UInt16)*curbyte) << 8);
  278.     return addr;
  279. }
  280.  
  281. //////////////////////////////////////////////
  282. //
  283. // GetIndirectPCAddress
  284. //
  285. //////////////////////////////////////////////
  286. UInt16 GetIndirectPCAddress(void)
  287. {
  288.     UInt16 addr;
  289.     UInt16* newAdder;
  290.     
  291.     addr = (UInt16) GetAbsolutePCAddress();
  292.     newAdder = (UInt16*) (gStartofProg + addr);
  293.     addr = ((*newAdder) << 8) | ((*newAdder) >> 8);
  294.     return addr;
  295. }
  296.